package com.proton.carepatchtemp.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.apkfuns.logutils.LogUtils;
import com.proton.carepatchtemp.BuildConfig;
import com.proton.carepatchtemp.R;
import com.proton.carepatchtemp.base.BaseActivity;
import com.proton.carepatchtemp.listener.NoDoubleClickListener;
import com.proton.carepatchtemp.utils.AppUtils;
import com.proton.carepatchtemp.utils.eventbus.MainEvent;


public class AboutProtonActivity extends BaseActivity {
    private ImageButton mBtn_back;
    private TextView mTv_phone_number;
    private TextView mTv_app_version;

    @Override
    public void dealEvent(MainEvent event) {

    }

    @Override
    public void setListener() {

        mTv_phone_number.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                Intent intent = new Intent(Intent.ACTION_DIAL);
                intent.setData(Uri.parse("tel:" + "400-826-5551"));
                try {
                    AboutProtonActivity.this.startActivity(intent);
                } catch (Throwable e) {
                    LogUtils.e(e);
                }
            }
        });

        mBtn_back.setOnClickListener(view -> {
            finish();
        });
    }

    private void bindViews() {
        mTv_app_version = findViewById(R.id.tv_app_version);
        mBtn_back = findViewById(R.id.btn_back);
        mTv_phone_number = findViewById(R.id.tv_phone_number);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_proton);
        bindViews();
        setListener();

        mTv_app_version.setText(AppUtils.getVersionName() + "  Build  " + AppUtils.getVersionCode() + "  " + BuildConfig.BUILD_TYPE);
    }

    @Override
    public void onEventMainThread(MainEvent event) {
        LogUtils.e(event.getId());
        dealOnEvent(event);
    }
}
